import { ref } from 'vue';

export default function useDict() {
  const dictData = ref([]);

  const getDict = async (dictType) => {
    try {
      const res = await getDictData(dictType);
      dictData.value = res.data.data.map(item => ({
        label: item.dictCode,
        value: item.dictValue
      }));
    } catch (error) {
      console.error('获取字典失败:', error);
    }
  };

  return {
    dictData,
    getDict
  };
}